﻿/// <summary>
///
/// </summary>
using md.imi.membranes.objects.membranes;

namespace md.imi.membranes.objects.rules
{
    using System;
    using md.imi.membranes.objects.strings;

    [Serializable]
    public class LeftHandRule : Rule
    {

        /// <summary>
        ///     The substring of the string from the membrane where the rule is applied
        /// </summary>
        public StringObject SubstringPattern;


        public LeftHandRule()
        {
        }

        public LeftHandRule (LeftHandRule rule) : base (rule)
        {
            this.SubstringPattern = new StringObject(rule.SubstringPattern);
        }

        /// <summary>
        ///     To string
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            if (string.IsNullOrEmpty(Label))
                return SubstringPattern != null ? SubstringPattern.ToString() : "";
            else
                return String.Format("{0}:{1}", Label, SubstringPattern != null ? SubstringPattern.ToString() : "");
        }

        /// <summary>
        ///     Apply current rule
        /// </summary>
        /// <param name="so"></param>
        /// <returns></returns>
        internal void ApplyRule(Solution solution, MembranesTree newMembrane, psystems.PSystemsTree parrentConfig)
        {
            throw new NotImplementedException();
        }
        
        public override Rule GetCopy ()
        {
            var newRule = new LeftHandRule(this);
            return newRule;
        }
    }
}